package com.mccken.practice.top100.Top_30$.Top_35;

import com.mccken.practice.top100.TreeNode;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2024-03-04 23:30
 **/
public class MaxDepth {
	public int maxDepth(TreeNode root) {
		if (root == null) {
			return 0;
		}

		return temp(root);
	}

	private Integer temp(TreeNode node) {

		if (node == null) {
			return 0;
		}
		
		int leftDepth = temp(node.left);
		int rightDepth = temp(node.right);
		return Integer.max(leftDepth, rightDepth) + 1;
		
	}

}
